import { DependencyList, RefObject } from "react";
import useLazyLoad, { ObserverCallback } from "./lazyLoad";
/**触底加载hook - intersectionObserver版 - 触底后只加载一次，除非依赖项变化
 * @param footer 触底时看到的元素的ref
 * @param onEntering 触底的回调函数  
 * @param deps useEffect的依赖数组 （当什么变化时，需要重新开始触底加载流程）
 * @param onDestroy useEffect的return中要做的事
 */
const useBottomLoading = (footer: RefObject<HTMLDivElement>, onEntering: ObserverCallback, deps: DependencyList = [], onDestroy?: () => void) => {
    useLazyLoad(footer, onEntering, onDestroy, deps)
}
export default useBottomLoading